<?php
JLoader::register('ProvinceHelper', JPATH_SITE.'/components/com_city/helper.php');

$jobcityList = empty($_['jobcityList']) ? null : $_['jobcityList'];
$folderList = empty($_['folderList']) ? null : $_['folderList'];
$type = empty($_['type']) ? '' : $_['type'];
$syncaction = empty($_['syncaction']) ? '' : $_['syncaction'];
$curfolderid = empty($_['curfolderid']) ? '' : $_['curfolderid'];
$selectjobtitle = empty($_['selectjobtitle']) ? '' : $_['selectjobtitle'];
$curcityids = empty($_['curcityids'])?array():$_['curcityids'];
$edit = empty($_['edit']) ? 0 : $_['edit'];
$loginstatus = empty($_['loginstatus']) ? 0 : $_['loginstatus'];
$dirInfo = empty($_['dirInfo']) ? array() : $_['dirInfo'];
$autorenewfolderid = empty($_['autorenewfolderid']) ? 0 : $_['autorenewfolderid'];

$source = '';
switch ($type){
   case '51job':
      $source = '前程无忧';
   break;
   case 'zhilian':
      $source = '智联招聘';
   break;
   case 'lagou':
      $source = '拉勾';
   break;
   case 'jiancai':
      $source = '建筑英才';
   break;
   default:
   break;
}
?>

<div class="modal-header">
   <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
   <h3>自动刷新</h3>
</div>

<div class="modal-body">
   <div class="autorn_poscontent">
      <div class="autorn_posyelwrap clearfix">
         <label class="pull-left">已选职位：</label>
         <div class="autorn_posyeltagit">
         <?php if(empty($selectjobtitle)): ?>
            <span>请选择需要刷新的职位</span>
         <?php else: ?>
            <ul class="tagbox inputbox tagit">
               <li class="tagit-choice"><span class="tagit-label"><?=$selectjobtitle ?></span><a class="tagit-close"><span class="text-icon">×</span><span><i class="icon-remove"></i></span></a></li>
            </ul>
            <?php endif; ?>
         </div>
      </div>
      <div class="autorn_selectpos">
        <div class="bgautorn_tl">选择<?=$source ?>职位</div>
        <div class="medium" style="padding:0 15px;">
           <div class="dir_eachselect clearfix">
              <b class="pull-left">文件夹</b>
              <div class="tj_octargets">
                 <a href="javascript:;" data-cityid="" data-type="1" data-folderid="-1" class="<?php echo $curfolderid == -1 ? 'cur_a' : ''; ?>">全部职位</a>
                  <?
                  if (!empty($folderList)) {
                     foreach ($folderList as $f) {
                        echo '<a class="'.($curfolderid == $f->folder_id ? 'cur_a' : '').'" data-type="1" data-cityid="" data-folderid="'.$f->folder_id.'"  href="javascript:;">' . $f->folder_name . '</a>';
                     }
                  }
                  ?>                 
              </div>
           </div>
           <div class="dir_eachselect clearfix" id="citySelect">
              <b class="pull-left">地区</b>
              <div class="tj_octargets">
              <?php 
                 if(!empty($jobcityList)){
                    foreach ($jobcityList as $c) {
                       echo '<a  data-folderid="" data-cityid="' . $c['cityid'] . '" class="city ' . (in_array($c['cityid'], $curcityids) ? 'cur_a' : '') . '" href="javascript:;">' . (ProvinceHelper::getMuniProvinceId($c['cityid']) ? $c['province'] : $c['province'] . $c['city']) . '</a>';
                    }
                 }
              ?>
              </div>
           </div>
           <div class="dir_eachselect clearfix" style="border-bottom:0px;">
              <b class="pull-left">自定义</b>
              <div class="tj_octargets">
              <?php if(isset($dirInfo['data']) && isset($dirInfo['num']) && $dirInfo['num'] >0):?>
                 <a href="javascript:;" data-type="2" class="<?php  $data = json_decode($dirInfo['data'],true); if($data == "" || (isset($data['custom']) && $data['custom'] == true)){ echo 'cur_a'; }else{echo '';} ?>"><?=$dirInfo['num'] ?>个职位</a>
                 <span class="editspn" id="editcustom" data-foldername ="autorenewjobs_<?=$type ?>" data-folderid ="<?=$autorenewfolderid ?>"><img src="/images/3/greenedit.png"></span>
                 <?php else: ?>
                  <span id="createJobGroup" class="creat_posbtn showlist">新建职位组合</span>
                 <?php endif; ?>
              </div>
           </div>
        </div>
      </div>
      <div class="autotn_btnright"><a class="btn btn-info save" data-custom="<?=isset($dirInfo['custom'])?$dirInfo['custom']:0 ?>" data-loginstatus="<?=$loginstatus ?>" data-folderid="<?=$curfolderid ?>" data-type="<?=$type ?>" data-edit="<?=$edit ?>" data-syncaction="<?=$syncaction ?>" href="javascript:;">确认</a></div>
   </div>
</div>